/**
 * 1最多的行
 *
 * @USER: Administrator
 * @DATE: 2024/9/15 下午4:42
 * @VERSION: 1.0.0
 */
public class LC2643 {
    public static void main(String[] args) {

    }

    public int[] rowAndMaximumOnes(int[][] mat) {
        // 结果
        int[] res = new int[2];

        // 1最多的个数
        int maxCount = 0;

        // 用一个数组存每行1的个数
        int[] counts = new int[mat.length];

        for (int i = 0; i < mat.length; i++) {
            int sum = 0;
            for (int j = 0; j < mat[i].length; j++) {
                sum += mat[i][j];
            }
            if (sum > maxCount) {
                maxCount = sum;
            }
            counts[i] = sum;
        }

        for (int i = 0; i < counts.length; i++) {
            if (counts[i] == maxCount) {
                res[0] = i;
                res[1] = maxCount;
                break;
            }
        }

        return res;
    }

}
